#include<iostream>
#include<stack>
using namespace std;
int main()
{
	int a, b;
	char c;
	cin >> a;
	int m = 10000;
	a %= 10000;
	stack<int> st;
	st.push(a);
	while (cin >> c >> b)
	{
		if (c == '*')
		{
			a = st.top();
			st.pop();
			st.push(a * b % m);
		}
		else st.push(b);
	}
	int sum = 0;
	while (!st.empty())
	{
		sum += st.top();
		sum %= m;
		st.pop();
	}
	cout << sum;
	return 0;
}